﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CtrlMonthDepartment1.ascx.cs" Inherits="Thksoft.UserCotrols.CtrlMonthDepartment1" %>

<style type="text/css">
    .Apply-Row-Lev-1 {
        background-color: #B2D8FF;
        font-size: 14px;
    }

    .Apply-Row-Lev-2 {
        background-color: #CCCCCC;
        font-size: 13px;
    }

    .Apply-Row-Lev-3 {
        background-color: white;
        font-size: 12px;
    }

    .Apply-Row-Lev-1 .INPUT {
        background-color: #B2D8FF;
        border-color: white;
    }

    .Apply-Row-Lev-2 .INPUT {
        background-color: #CCCCCC;
        border-color: white;
    }

    .Apply-Row-Lev-3 .INPUT {
        border-color: white;
    }
</style>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <asp:Button CssClass="hide" runat="server" ID="ReLoadBtn" OnClick="ReLoadBtn_Click" />
    <%
        var appStr = "window." + this.ClientID;
        if (this.Model.Where(a => Convert.ToInt32(a["N_AMOUNT"]) == 0 && a["N_TYPE"].ToObject<int>() == 2).Count() == this.Model.Where(a => a["N_TYPE"].ToObject<int>() == 2).Count())
        {
    %>
    <tr>
        <td>你还没有汇总资金计划。<a onclick="<%=(appStr+".EditClick();") %>" style="color: blue;">直接添加</a></td>
    </tr>
    <%
        }
        else
        {
    %>
    <tr>
        <td>你已汇总资金计划。<a onclick="<%=(appStr+".EditClick();") %> " style="color: blue;">进行修改</a></td>
    </tr>
    <tr>
        <td>
            <table class="table" width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr style="background-color: #29a1f7; opacity: 0.7; font-size: 16px;">
                    <th style="border: 1px solid #BAD4E1; text-align: center; color: white;">编号</th>
                    <th style="border: 1px solid #BAD4E1; text-align: center; color: white;">项目名称</th>
                    <th style="border: 1px solid #BAD4E1; text-align: center; color: white;">申请金额</th>
                    <th style="border: 1px solid #BAD4E1; text-align: center; color: white;">备注</th>
                </tr>
                <%
                    foreach (var item in this.Model)
                    {
                %>

                <% var applyId = item["N_MONTHAPP_ID"].ToString(); %>
                <% var proId = item["N_PROID"].ToString(); %>
                <% var code = item["C_DETAILS_CODE"].ToString(); %>

                <% if (item["N_TYPE"].ToObject<int>() == 0)
                    { %>
                <tr class="Apply-Row-Lev-1">
                    <% }
                        else if (item["N_TYPE"].ToObject<int>() == 1)
                        { %>
                <tr class="Apply-Row-Lev-2">
                    <%}
                        else
                        {%>
                <tr class="Apply-Row-Lev-3">
                    <%} %>

                    <td><%=item["N_PROID"].ToString() %></td>
                    <td><%=item["C_PRONAME"].ToString() %></td>
                    <td ondblclick="FORM_Details(<%=applyId %>,<%=proId %>,'<%=code %>')" style="vertical-align: middle; text-align: center;">
                        <div style="float: left;">
                            <%=item["N_AMOUNT"].Equals(Newtonsoft.Json.Linq.JValue.CreateNull())?"未填报":Utility.Helper.HtmlHelper.QyFormat(item["N_AMOUNT"].ToObject<decimal>()) %>
                        </div>
                        <div style="float: right; top: 7px; right: 4px; position: relative;">
                            <% if (item["C_IMAGE_URL"] != null)
                                { %>
                            <img src="<%=item["C_IMAGE_URL"].ToString() %>" style="vertical-align: middle;"></img>
                            <% } %>
                        </div>
                    </td>
                    <td><%=item["C_REMARK"].ToString() %></td>
                </tr>
                <%
                        }
                    }
                %>
            </table>
        </td>
    </tr>
</table>
<script src="/Scripts/jquery.1.11.1.js"></script>
<script>
    //金额详情
    function FORM_Details(applyId, proId, code) {
        var applyId = applyId;
        var type = 2;
        var proId = proId;
        var code = code;
        var arry = [
            { Code: "T1", Url: "/Module/ProjectDetails/IncomeBusiness.aspx", Title: "主营业务收入月明细表" }, //IncomeOne.aspx
            { Code: "T2", Url: "/Module/ProjectDetails/OutcomeGasMoney.aspx", Title: "天然气购入月明细表" },
            { Code: "T3", Url: "/Module/ProjectDetails/OutcomeThree.aspx", Title: "安装外包费用月明细表" },
            { Code: "T4", Url: "/Module/ProjectDetails/OutcomeFour.aspx", Title: "材料费用月明细表" },
            { Code: "T5", Url: "/Module/ProjectDetails/OutcomeFive.aspx", Title: "大修费用月明细表" },
            { Code: "T6", Url: "/Module/ProjectDetails/OutcomeInvestment1.aspx", Title: "城市管网项目月明细表" }
        ]
        for (var i = 0; i < arry.length; i++) {
            if (arry[i].Code == code) {
                var url = arry[i].Url;
                url += "?ApplyId=" + applyId;
                url += "&ProId=" + proId;
                url += "&State=" + type;
                url += "&type=0 "; //判断是0计划上报 1单位审批 2总部审批
                url += "&Select=sel";
                //直接调用主页面的Layer  https://www.layui.com/doc/modules/layer.html
                var option = {
                    title: arry[i].Title,
                    type: 2,
                    content: [url, 'no'],
                    area: ["850px", "530px"],
                    scrollbar: false
                };
                top.layer.open(option);
                return;
            }
        }
    }

    !function () {
        var key = "<%=this.ClientID%>";
        var reLoadBtn = "<%=this.ReLoadBtn.ClientID %>";
        window[key] = {};
        var app = window[key];
        //编辑事件
        app.EditClick = function () {
            //直接调用Layer
            var option = {};
            option.type = 2;
            option.content = ["/Module/ApplyView/Apply/Edit/MonthHz.aspx?ApplyId=<%=this.ApplyId%>", "no"];
            option.title = "编辑资金计划";
            option.area = ["800px", "600px"];
            option.end = function () {
                console.log("刷新了");
                app.Reload();

            };
            top.layer.open(option);
        };
        //刷新页面事件
        app.Reload = function () {
            $("#" + reLoadBtn).click();
        };
        console.log(key);
        console.log(window[key]);
    }();
</script>